<?php


namespace app\admin\model\Feedback;


use think\facade\Db;
use think\Model;

class UserFeedbackModel extends Model
{

    /**
     * 数据表名
     * @var string
     */
    protected $name = "user_feedback";

    /**
     * 根据条件查询多条数据
     * @param $where
     * @return array
     * @throws
     */
    public static function getUserFeedbackWhereMore($where)
    {
        $list = Db::name("user_feedback")->where($where)->select()->toArray();
        return $list;
    }

    /**
     * 统计总数
     * @param $where
     * @return int
     */
    public static function getUserFeedbackCountWhere($where)
    {
        $count = Db::name("user_feedback")->where($where)->count();
        return $count;
    }

    /**
     * 分页查询
     * @param $page
     * @param $limit
     * @param $where
     * @return mixed
     * @throws
     */
    public static function getUserFeedbackListWhere($page,$limit,$where = [],$field="*")
    {
        $start = ceil(($page-1)*$limit);
        $list = Db::name('user_feedback')->field($field)->where($where)->limit($start,$limit)->select()->toArray();
        return $list;
    }

    /**
     * 添加返回ID
     * @param $data
     * @return int
     */
    public static function addUserFeedback($data)
    {
        $id = Db::name('user_feedback')->insertGetId($data);
        return $id;
    }

    /**
     * 更新
     * @param $where
     * @param $save
     * @return int
     * @throws
     */
    public static function updateUserFeedbackWhere($where,$save)
    {
        $flag = Db::name('user_feedback')->where($where)->update($save);
        return $flag;
    }

    /**
     * 删除
     * @param $where
     * @return int
     * @throws
     */
    public static function delUserFeedbackWhere($where)
    {
        $flag = Db::name('user_feedback')->where($where)->delete();
        return $flag;
    }

}